<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>输入、删除、修改成绩</title>
    <script type="text/javascript">
        function add() {
            var name = stuName.value;
            var score = stuScore.value;
            if (!isNaN(score) && name != ''){
                info.innerHTML = info.innerHTML +
                    "<tr><td>" + name + "</td><td>" + score +
                    "</td><td><input type='button' value='删除' onclick='delete1(this)'/></td>" +
                    "<td><input type='button' value='修改' onclick='update(this)'/></td></tr>"
            }
            else {
                alert('输入有误！')
            }
        }
        function delete1(r) {
            var i = r.parentNode.parentNode.rowIndex;
            var row = info.rows[i];
            var cells = row.cells;
            if (confirm('你确定要删除'+cells[0].innerText+"的成绩吗？")){
                document.getElementById('info').delete1(i);
            }
        }
        function update(r) {
            var i = r.parentNode.parentNode.rowIndex;
            var row = info.rows[i];
            var cells = row.cells;
            var name = prompt("请输入姓名：");
            var score = prompt("请输入分数：");
            if ((name!=''&&name!=null) && (!isNaN(score)&&score!='')){
                cells[0].innerText = name;
                cells[1].innerText = score
            }
            else {
                alert("输入信息有误！")
            }
        }
    </script>
</head>
<body>
<form action="">
    <input type="text" id="stuName">
    <input type="text" id="stuScore">
    <button type="button" onclick="add()">输入</button>
    <br>
    <table id="info">

    </table>
</form>
</body>
</html>